package com.example.gmr.Helper;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.Toast;

import java.util.HashMap;
import java.util.Map;

public class SharedPreferenceHelper {

    private Context context;

    public SharedPreferenceHelper() {

    }
    public SharedPreferenceHelper(Context context) {
        this.context = context;
    }
    public void save(String username, String password){
        SharedPreferences sp=context.getSharedPreferences("ynBeauty", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putString("username",username);
        editor.putString("password",password);
        editor.commit();
        Toast.makeText(context,"注册成功", Toast.LENGTH_SHORT).show();
    }
    public Map<String, String> read(){
        Map<String, String> data=new HashMap<>();
        SharedPreferences sp=context.getSharedPreferences("ynBeauty", Context.MODE_PRIVATE);
        data.put("username",sp.getString("username",""));
        data.put("password",sp.getString("password",""));
        return data;
    }
}
